﻿using NoMiddleman.Core.Domain;

namespace NoMiddleman.Facades.DataTransferObjects
{
    public class AddressDTO
    {
        public int Id { get; set; }

        public string City { get; set; }

        public string Street { get; set; }

        public int Number { get; set; }

        public int? FlatNumber { get; set; }
    }

    public class AddressFactory
    {
        public static Address GetAddress(AddressDTO addressDto)
        {
            return new Address
                                  {
                                      City = addressDto.City,
                                      FlatNumber = addressDto.FlatNumber,
                                      Number = addressDto.Number,
                                      Street = addressDto.Street
                                  };
        }

        public static AddressDTO GetAddressDTO(Address address)
        {
            return new AddressDTO
                       {
                           Id = address.Id,
                           City = address.City,
                           FlatNumber = address.FlatNumber,
                           Number = address.Number,
                           Street = address.Street
                       };
        }
    }
}